<template>
  <div class="page flex-end">
    <el-pagination background
                   @size-change="handleSizeChange"
                   @current-change="handleCurrentChange"
                   layout="total, sizes, prev, pager, next, jumper"
                   :current-page.sync="page.current"
                   :page-size.sync="page.size"
                   :page-sizes="[10, 20, 100, 200, 300, 400]"
                   :total="total">
    </el-pagination>
  </div>
</template>

<script>

export default {
  name: "app-pagination",
  props: {
    initValue: {
      type: Object,
      default: null
    },
    total: {
      type: Number,
      default: 0
    },
    pageSize: {
      type: Number,
      default: 10
    }
  },
  data() {
    return {
      page: {
        size: 20,
        current: 1
      },
    }
  },
  created() {
    this.page.size = this.pageSize
  },
  methods: {
    reset() {
      this.page.current = 1
      this.$emit('do-query', this.page)
      this.$emit('change', this.page)
    },
    handleSizeChange(val) {
      this.current = 1
      this.$emit('do-query', this.page)
      this.$emit('change', this.page)
    },
    handleCurrentChange(val) {
      this.$emit('do-query', this.page)
      this.$emit('change', this.page)
    },
    getPage() {
      return this.page
    }
  }
}
</script>

<style lang="scss" scoped>

.page {
  /deep/ .el-input__inner {
    font-size: 13px !important;
    line-height: 28px !important;
    height: 28px !important;
  }
}

</style>
